<?php

/**
 * Shipment.
 *
 * PHP version 8.3
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */

/**
 * The Selling Partner API for FBA inbound operations.
 *
 * The Selling Partner API for Fulfillment By Amazon (FBA) Inbound. The FBA Inbound API enables building inbound workflows to create, manage, and send shipments into Amazon's fulfillment network. The API has interoperability with the Send-to-Amazon user interface.
 *
 * The version of the OpenAPI document: 2024-03-20
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.9.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace SpApi\Model\fulfillment\inbound\v2024_03_20;

use SpApi\Model\ModelInterface;
use SpApi\ObjectSerializer;

/**
 * Shipment Class Doc Comment.
 *
 * @category Class
 *
 * @description Contains information pertaining to a shipment in an inbound plan.
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 *
 * @implements \ArrayAccess<string, mixed>
 */
class Shipment implements ModelInterface, \ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

    /**
     * The original name of the model.
     */
    protected static string $openAPIModelName = 'Shipment';

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static array $openAPITypes = [
        'amazon_reference_id' => 'string',
        'contact_information' => '\SpApi\Model\fulfillment\inbound\v2024_03_20\ContactInformation',
        'dates' => '\SpApi\Model\fulfillment\inbound\v2024_03_20\Dates',
        'destination' => '\SpApi\Model\fulfillment\inbound\v2024_03_20\ShipmentDestination',
        'freight_information' => '\SpApi\Model\fulfillment\inbound\v2024_03_20\FreightInformation',
        'name' => 'string',
        'placement_option_id' => 'string',
        'selected_delivery_window' => '\SpApi\Model\fulfillment\inbound\v2024_03_20\SelectedDeliveryWindow',
        'selected_transportation_option_id' => 'string',
        'self_ship_appointment_details' => '\SpApi\Model\fulfillment\inbound\v2024_03_20\SelfShipAppointmentDetails[]',
        'shipment_confirmation_id' => 'string',
        'shipment_id' => 'string',
        'source' => '\SpApi\Model\fulfillment\inbound\v2024_03_20\ShipmentSource',
        'status' => 'string',
        'tracking_details' => '\SpApi\Model\fulfillment\inbound\v2024_03_20\TrackingDetails'];

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @var string[]
     *
     * @phpstan-var array<string, string|null>
     *
     * @psalm-var array<string, string|null>
     */
    protected static array $openAPIFormats = [
        'amazon_reference_id' => null,
        'contact_information' => null,
        'dates' => null,
        'destination' => null,
        'freight_information' => null,
        'name' => null,
        'placement_option_id' => null,
        'selected_delivery_window' => null,
        'selected_transportation_option_id' => null,
        'self_ship_appointment_details' => null,
        'shipment_confirmation_id' => null,
        'shipment_id' => null,
        'source' => null,
        'status' => null,
        'tracking_details' => null];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'amazon_reference_id' => true,
        'contact_information' => true,
        'dates' => true,
        'destination' => false,
        'freight_information' => true,
        'name' => true,
        'placement_option_id' => false,
        'selected_delivery_window' => true,
        'selected_transportation_option_id' => true,
        'self_ship_appointment_details' => true,
        'shipment_confirmation_id' => true,
        'shipment_id' => false,
        'source' => false,
        'status' => true,
        'tracking_details' => true,
    ];

    /**
     * If a nullable field gets set to null, insert it here.
     *
     * @var bool[]
     */
    protected array $openAPINullablesSetToNull = [];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @var string[]
     */
    protected static array $attributeMap = [
        'amazon_reference_id' => 'amazonReferenceId',
        'contact_information' => 'contactInformation',
        'dates' => 'dates',
        'destination' => 'destination',
        'freight_information' => 'freightInformation',
        'name' => 'name',
        'placement_option_id' => 'placementOptionId',
        'selected_delivery_window' => 'selectedDeliveryWindow',
        'selected_transportation_option_id' => 'selectedTransportationOptionId',
        'self_ship_appointment_details' => 'selfShipAppointmentDetails',
        'shipment_confirmation_id' => 'shipmentConfirmationId',
        'shipment_id' => 'shipmentId',
        'source' => 'source',
        'status' => 'status',
        'tracking_details' => 'trackingDetails',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static array $setters = [
        'amazon_reference_id' => 'setAmazonReferenceId',
        'contact_information' => 'setContactInformation',
        'dates' => 'setDates',
        'destination' => 'setDestination',
        'freight_information' => 'setFreightInformation',
        'name' => 'setName',
        'placement_option_id' => 'setPlacementOptionId',
        'selected_delivery_window' => 'setSelectedDeliveryWindow',
        'selected_transportation_option_id' => 'setSelectedTransportationOptionId',
        'self_ship_appointment_details' => 'setSelfShipAppointmentDetails',
        'shipment_confirmation_id' => 'setShipmentConfirmationId',
        'shipment_id' => 'setShipmentId',
        'source' => 'setSource',
        'status' => 'setStatus',
        'tracking_details' => 'setTrackingDetails',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static array $getters = [
        'amazon_reference_id' => 'getAmazonReferenceId',
        'contact_information' => 'getContactInformation',
        'dates' => 'getDates',
        'destination' => 'getDestination',
        'freight_information' => 'getFreightInformation',
        'name' => 'getName',
        'placement_option_id' => 'getPlacementOptionId',
        'selected_delivery_window' => 'getSelectedDeliveryWindow',
        'selected_transportation_option_id' => 'getSelectedTransportationOptionId',
        'self_ship_appointment_details' => 'getSelfShipAppointmentDetails',
        'shipment_confirmation_id' => 'getShipmentConfirmationId',
        'shipment_id' => 'getShipmentId',
        'source' => 'getSource',
        'status' => 'getStatus',
        'tracking_details' => 'getTrackingDetails',
    ];

    /**
     * Associative array for storing property values.
     */
    protected array $container = [];

    /**
     * Constructor.
     *
     * @param null|array $data Associated array of property values
     *                         initializing the model
     */
    public function __construct(?array $data = null)
    {
        $this->setIfExists('amazon_reference_id', $data ?? [], null);
        $this->setIfExists('contact_information', $data ?? [], null);
        $this->setIfExists('dates', $data ?? [], null);
        $this->setIfExists('destination', $data ?? [], null);
        $this->setIfExists('freight_information', $data ?? [], null);
        $this->setIfExists('name', $data ?? [], null);
        $this->setIfExists('placement_option_id', $data ?? [], null);
        $this->setIfExists('selected_delivery_window', $data ?? [], null);
        $this->setIfExists('selected_transportation_option_id', $data ?? [], null);
        $this->setIfExists('self_ship_appointment_details', $data ?? [], null);
        $this->setIfExists('shipment_confirmation_id', $data ?? [], null);
        $this->setIfExists('shipment_id', $data ?? [], null);
        $this->setIfExists('source', $data ?? [], null);
        $this->setIfExists('status', $data ?? [], null);
        $this->setIfExists('tracking_details', $data ?? [], null);
    }

    /**
     * Gets the string presentation of the object.
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

    /**
     * Array of property to type mappings. Used for (de)serialization.
     */
    public static function openAPITypes(): array
    {
        return self::$openAPITypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization.
     */
    public static function openAPIFormats(): array
    {
        return self::$openAPIFormats;
    }

    /**
     * Checks if a property is nullable.
     */
    public static function isNullable(string $property): bool
    {
        return self::openAPINullables()[$property] ?? false;
    }

    /**
     * Checks if a nullable property is set to null.
     */
    public function isNullableSetToNull(string $property): bool
    {
        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     */
    public static function attributeMap(): array
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     */
    public static function setters(): array
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests).
     */
    public static function getters(): array
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     */
    public function getModelName(): string
    {
        return self::$openAPIModelName;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties(): array
    {
        $invalidProperties = [];

        if (!is_null($this->container['amazon_reference_id']) && (mb_strlen($this->container['amazon_reference_id']) > 1024)) {
            $invalidProperties[] = "invalid value for 'amazon_reference_id', the character length must be smaller than or equal to 1024.";
        }

        if (!is_null($this->container['amazon_reference_id']) && (mb_strlen($this->container['amazon_reference_id']) < 1)) {
            $invalidProperties[] = "invalid value for 'amazon_reference_id', the character length must be bigger than or equal to 1.";
        }

        if (null === $this->container['destination']) {
            $invalidProperties[] = "'destination' can't be null";
        }
        if (null === $this->container['placement_option_id']) {
            $invalidProperties[] = "'placement_option_id' can't be null";
        }
        if (mb_strlen($this->container['placement_option_id']) > 38) {
            $invalidProperties[] = "invalid value for 'placement_option_id', the character length must be smaller than or equal to 38.";
        }

        if (mb_strlen($this->container['placement_option_id']) < 38) {
            $invalidProperties[] = "invalid value for 'placement_option_id', the character length must be bigger than or equal to 38.";
        }

        if (!preg_match('/^[a-zA-Z0-9-]*$/', $this->container['placement_option_id'])) {
            $invalidProperties[] = "invalid value for 'placement_option_id', must be conform to the pattern /^[a-zA-Z0-9-]*$/.";
        }

        if (!is_null($this->container['selected_transportation_option_id']) && (mb_strlen($this->container['selected_transportation_option_id']) > 38)) {
            $invalidProperties[] = "invalid value for 'selected_transportation_option_id', the character length must be smaller than or equal to 38.";
        }

        if (!is_null($this->container['selected_transportation_option_id']) && (mb_strlen($this->container['selected_transportation_option_id']) < 38)) {
            $invalidProperties[] = "invalid value for 'selected_transportation_option_id', the character length must be bigger than or equal to 38.";
        }

        if (!is_null($this->container['selected_transportation_option_id']) && !preg_match('/^[a-zA-Z0-9-]*$/', $this->container['selected_transportation_option_id'])) {
            $invalidProperties[] = "invalid value for 'selected_transportation_option_id', must be conform to the pattern /^[a-zA-Z0-9-]*$/.";
        }

        if (!is_null($this->container['shipment_confirmation_id']) && (mb_strlen($this->container['shipment_confirmation_id']) > 1024)) {
            $invalidProperties[] = "invalid value for 'shipment_confirmation_id', the character length must be smaller than or equal to 1024.";
        }

        if (!is_null($this->container['shipment_confirmation_id']) && (mb_strlen($this->container['shipment_confirmation_id']) < 1)) {
            $invalidProperties[] = "invalid value for 'shipment_confirmation_id', the character length must be bigger than or equal to 1.";
        }

        if (null === $this->container['shipment_id']) {
            $invalidProperties[] = "'shipment_id' can't be null";
        }
        if (mb_strlen($this->container['shipment_id']) > 38) {
            $invalidProperties[] = "invalid value for 'shipment_id', the character length must be smaller than or equal to 38.";
        }

        if (mb_strlen($this->container['shipment_id']) < 38) {
            $invalidProperties[] = "invalid value for 'shipment_id', the character length must be bigger than or equal to 38.";
        }

        if (!preg_match('/^[a-zA-Z0-9-]*$/', $this->container['shipment_id'])) {
            $invalidProperties[] = "invalid value for 'shipment_id', must be conform to the pattern /^[a-zA-Z0-9-]*$/.";
        }

        if (null === $this->container['source']) {
            $invalidProperties[] = "'source' can't be null";
        }
        if (!is_null($this->container['status']) && (mb_strlen($this->container['status']) > 1024)) {
            $invalidProperties[] = "invalid value for 'status', the character length must be smaller than or equal to 1024.";
        }

        if (!is_null($this->container['status']) && (mb_strlen($this->container['status']) < 1)) {
            $invalidProperties[] = "invalid value for 'status', the character length must be bigger than or equal to 1.";
        }

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed.
     *
     * @return bool True if all properties are valid
     */
    public function valid(): bool
    {
        return 0 === count($this->listInvalidProperties());
    }

    /**
     * Gets amazon_reference_id.
     */
    public function getAmazonReferenceId(): ?string
    {
        return $this->container['amazon_reference_id'];
    }

    /**
     * Sets amazon_reference_id.
     *
     * @param null|string $amazon_reference_id a unique identifier created by Amazon that identifies this Amazon-partnered, Less Than Truckload/Full Truckload (LTL/FTL) shipment
     */
    public function setAmazonReferenceId(?string $amazon_reference_id): self
    {
        if (is_null($amazon_reference_id)) {
            array_push($this->openAPINullablesSetToNull, 'amazon_reference_id');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('amazon_reference_id', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        if (!is_null($amazon_reference_id) && (mb_strlen($amazon_reference_id) > 1024)) {
            throw new \InvalidArgumentException('invalid length for $amazon_reference_id when calling Shipment., must be smaller than or equal to 1024.');
        }
        if (!is_null($amazon_reference_id) && (mb_strlen($amazon_reference_id) < 1)) {
            throw new \InvalidArgumentException('invalid length for $amazon_reference_id when calling Shipment., must be bigger than or equal to 1.');
        }

        $this->container['amazon_reference_id'] = $amazon_reference_id;

        return $this;
    }

    /**
     * Gets contact_information.
     */
    public function getContactInformation(): ?ContactInformation
    {
        return $this->container['contact_information'];
    }

    /**
     * Sets contact_information.
     *
     * @param null|ContactInformation $contact_information contact_information
     */
    public function setContactInformation(?ContactInformation $contact_information): self
    {
        if (is_null($contact_information)) {
            array_push($this->openAPINullablesSetToNull, 'contact_information');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('contact_information', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['contact_information'] = $contact_information;

        return $this;
    }

    /**
     * Gets dates.
     */
    public function getDates(): ?Dates
    {
        return $this->container['dates'];
    }

    /**
     * Sets dates.
     *
     * @param null|Dates $dates dates
     */
    public function setDates(?Dates $dates): self
    {
        if (is_null($dates)) {
            array_push($this->openAPINullablesSetToNull, 'dates');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('dates', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['dates'] = $dates;

        return $this;
    }

    /**
     * Gets destination.
     */
    public function getDestination(): ShipmentDestination
    {
        return $this->container['destination'];
    }

    /**
     * Sets destination.
     *
     * @param ShipmentDestination $destination destination
     */
    public function setDestination(ShipmentDestination $destination): self
    {
        if (is_null($destination)) {
            throw new \InvalidArgumentException('non-nullable destination cannot be null');
        }
        $this->container['destination'] = $destination;

        return $this;
    }

    /**
     * Gets freight_information.
     */
    public function getFreightInformation(): ?FreightInformation
    {
        return $this->container['freight_information'];
    }

    /**
     * Sets freight_information.
     *
     * @param null|FreightInformation $freight_information freight_information
     */
    public function setFreightInformation(?FreightInformation $freight_information): self
    {
        if (is_null($freight_information)) {
            array_push($this->openAPINullablesSetToNull, 'freight_information');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('freight_information', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['freight_information'] = $freight_information;

        return $this;
    }

    /**
     * Gets name.
     */
    public function getName(): ?string
    {
        return $this->container['name'];
    }

    /**
     * Sets name.
     *
     * @param null|string $name the name of the shipment
     */
    public function setName(?string $name): self
    {
        if (is_null($name)) {
            array_push($this->openAPINullablesSetToNull, 'name');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('name', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['name'] = $name;

        return $this;
    }

    /**
     * Gets placement_option_id.
     */
    public function getPlacementOptionId(): string
    {
        return $this->container['placement_option_id'];
    }

    /**
     * Sets placement_option_id.
     *
     * @param string $placement_option_id The identifier of a placement option. A placement option represents the shipment splits and destinations of SKUs.
     */
    public function setPlacementOptionId(string $placement_option_id): self
    {
        if (is_null($placement_option_id)) {
            throw new \InvalidArgumentException('non-nullable placement_option_id cannot be null');
        }
        if (mb_strlen($placement_option_id) > 38) {
            throw new \InvalidArgumentException('invalid length for $placement_option_id when calling Shipment., must be smaller than or equal to 38.');
        }
        if (mb_strlen($placement_option_id) < 38) {
            throw new \InvalidArgumentException('invalid length for $placement_option_id when calling Shipment., must be bigger than or equal to 38.');
        }
        if (!preg_match('/^[a-zA-Z0-9-]*$/', ObjectSerializer::toString($placement_option_id))) {
            throw new \InvalidArgumentException('invalid value for $placement_option_id when calling Shipment., must conform to the pattern /^[a-zA-Z0-9-]*$/.');
        }

        $this->container['placement_option_id'] = $placement_option_id;

        return $this;
    }

    /**
     * Gets selected_delivery_window.
     */
    public function getSelectedDeliveryWindow(): ?SelectedDeliveryWindow
    {
        return $this->container['selected_delivery_window'];
    }

    /**
     * Sets selected_delivery_window.
     *
     * @param null|SelectedDeliveryWindow $selected_delivery_window selected_delivery_window
     */
    public function setSelectedDeliveryWindow(?SelectedDeliveryWindow $selected_delivery_window): self
    {
        if (is_null($selected_delivery_window)) {
            array_push($this->openAPINullablesSetToNull, 'selected_delivery_window');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('selected_delivery_window', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['selected_delivery_window'] = $selected_delivery_window;

        return $this;
    }

    /**
     * Gets selected_transportation_option_id.
     */
    public function getSelectedTransportationOptionId(): ?string
    {
        return $this->container['selected_transportation_option_id'];
    }

    /**
     * Sets selected_transportation_option_id.
     *
     * @param null|string $selected_transportation_option_id Identifier of a transportation option. A transportation option represent one option for how to send a shipment.
     */
    public function setSelectedTransportationOptionId(?string $selected_transportation_option_id): self
    {
        if (is_null($selected_transportation_option_id)) {
            array_push($this->openAPINullablesSetToNull, 'selected_transportation_option_id');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('selected_transportation_option_id', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        if (!is_null($selected_transportation_option_id) && (mb_strlen($selected_transportation_option_id) > 38)) {
            throw new \InvalidArgumentException('invalid length for $selected_transportation_option_id when calling Shipment., must be smaller than or equal to 38.');
        }
        if (!is_null($selected_transportation_option_id) && (mb_strlen($selected_transportation_option_id) < 38)) {
            throw new \InvalidArgumentException('invalid length for $selected_transportation_option_id when calling Shipment., must be bigger than or equal to 38.');
        }
        if (!is_null($selected_transportation_option_id) && (!preg_match('/^[a-zA-Z0-9-]*$/', ObjectSerializer::toString($selected_transportation_option_id)))) {
            throw new \InvalidArgumentException('invalid value for $selected_transportation_option_id when calling Shipment., must conform to the pattern /^[a-zA-Z0-9-]*$/.');
        }

        $this->container['selected_transportation_option_id'] = $selected_transportation_option_id;

        return $this;
    }

    /**
     * Gets self_ship_appointment_details.
     */
    public function getSelfShipAppointmentDetails(): ?array
    {
        return $this->container['self_ship_appointment_details'];
    }

    /**
     * Sets self_ship_appointment_details.
     *
     * @param null|array $self_ship_appointment_details list of self ship appointment details
     */
    public function setSelfShipAppointmentDetails(?array $self_ship_appointment_details): self
    {
        if (is_null($self_ship_appointment_details)) {
            array_push($this->openAPINullablesSetToNull, 'self_ship_appointment_details');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('self_ship_appointment_details', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['self_ship_appointment_details'] = $self_ship_appointment_details;

        return $this;
    }

    /**
     * Gets shipment_confirmation_id.
     */
    public function getShipmentConfirmationId(): ?string
    {
        return $this->container['shipment_confirmation_id'];
    }

    /**
     * Sets shipment_confirmation_id.
     *
     * @param null|string $shipment_confirmation_id the confirmed shipment ID which shows up on labels (for example, `FBA1234ABCD`)
     */
    public function setShipmentConfirmationId(?string $shipment_confirmation_id): self
    {
        if (is_null($shipment_confirmation_id)) {
            array_push($this->openAPINullablesSetToNull, 'shipment_confirmation_id');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('shipment_confirmation_id', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        if (!is_null($shipment_confirmation_id) && (mb_strlen($shipment_confirmation_id) > 1024)) {
            throw new \InvalidArgumentException('invalid length for $shipment_confirmation_id when calling Shipment., must be smaller than or equal to 1024.');
        }
        if (!is_null($shipment_confirmation_id) && (mb_strlen($shipment_confirmation_id) < 1)) {
            throw new \InvalidArgumentException('invalid length for $shipment_confirmation_id when calling Shipment., must be bigger than or equal to 1.');
        }

        $this->container['shipment_confirmation_id'] = $shipment_confirmation_id;

        return $this;
    }

    /**
     * Gets shipment_id.
     */
    public function getShipmentId(): string
    {
        return $this->container['shipment_id'];
    }

    /**
     * Sets shipment_id.
     *
     * @param string $shipment_id Identifier of a shipment. A shipment contains the boxes and units being inbounded.
     */
    public function setShipmentId(string $shipment_id): self
    {
        if (is_null($shipment_id)) {
            throw new \InvalidArgumentException('non-nullable shipment_id cannot be null');
        }
        if (mb_strlen($shipment_id) > 38) {
            throw new \InvalidArgumentException('invalid length for $shipment_id when calling Shipment., must be smaller than or equal to 38.');
        }
        if (mb_strlen($shipment_id) < 38) {
            throw new \InvalidArgumentException('invalid length for $shipment_id when calling Shipment., must be bigger than or equal to 38.');
        }
        if (!preg_match('/^[a-zA-Z0-9-]*$/', ObjectSerializer::toString($shipment_id))) {
            throw new \InvalidArgumentException('invalid value for $shipment_id when calling Shipment., must conform to the pattern /^[a-zA-Z0-9-]*$/.');
        }

        $this->container['shipment_id'] = $shipment_id;

        return $this;
    }

    /**
     * Gets source.
     */
    public function getSource(): ShipmentSource
    {
        return $this->container['source'];
    }

    /**
     * Sets source.
     *
     * @param ShipmentSource $source source
     */
    public function setSource(ShipmentSource $source): self
    {
        if (is_null($source)) {
            throw new \InvalidArgumentException('non-nullable source cannot be null');
        }
        $this->container['source'] = $source;

        return $this;
    }

    /**
     * Gets status.
     */
    public function getStatus(): ?string
    {
        return $this->container['status'];
    }

    /**
     * Sets status.
     *
     * @param null|string $status The status of a shipment. The state of the shipment will typically start as `UNCONFIRMED`, then transition to `WORKING` after a placement option has been confirmed, and then to `READY_TO_SHIP` once labels are generated.  Possible values: `ABANDONED`, `CANCELLED`, `CHECKED_IN`, `CLOSED`, `DELETED`, `DELIVERED`, `IN_TRANSIT`, `MIXED`, `READY_TO_SHIP`, `RECEIVING`, `SHIPPED`, `UNCONFIRMED`, `WORKING`
     */
    public function setStatus(?string $status): self
    {
        if (is_null($status)) {
            array_push($this->openAPINullablesSetToNull, 'status');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('status', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        if (!is_null($status) && (mb_strlen($status) > 1024)) {
            throw new \InvalidArgumentException('invalid length for $status when calling Shipment., must be smaller than or equal to 1024.');
        }
        if (!is_null($status) && (mb_strlen($status) < 1)) {
            throw new \InvalidArgumentException('invalid length for $status when calling Shipment., must be bigger than or equal to 1.');
        }

        $this->container['status'] = $status;

        return $this;
    }

    /**
     * Gets tracking_details.
     */
    public function getTrackingDetails(): ?TrackingDetails
    {
        return $this->container['tracking_details'];
    }

    /**
     * Sets tracking_details.
     *
     * @param null|TrackingDetails $tracking_details tracking_details
     */
    public function setTrackingDetails(?TrackingDetails $tracking_details): self
    {
        if (is_null($tracking_details)) {
            array_push($this->openAPINullablesSetToNull, 'tracking_details');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('tracking_details', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['tracking_details'] = $tracking_details;

        return $this;
    }

    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param int $offset Offset
     */
    public function offsetExists($offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param int $offset Offset
     *
     * @return null|mixed
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset): mixed
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     *
     * @param null|int $offset Offset
     * @param mixed    $value  Value to be set
     */
    public function offsetSet($offset, mixed $value): void
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param int $offset Offset
     */
    public function offsetUnset($offset): void
    {
        unset($this->container[$offset]);
    }

    /**
     * Serializes the object to a value that can be serialized natively by json_encode().
     *
     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
     *
     * @return mixed returns data which can be serialized by json_encode(), which is a value
     *               of any type other than a resource
     */
    #[\ReturnTypeWillChange]
    public function jsonSerialize(): mixed
    {
        return ObjectSerializer::sanitizeForSerialization($this);
    }

    /**
     * Gets a header-safe presentation of the object.
     */
    public function toHeaderValue(): string
    {
        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }

    /**
     * Array of nullable properties.
     */
    protected static function openAPINullables(): array
    {
        return self::$openAPINullables;
    }

    /**
     * Array of nullable field names deliberately set to null.
     *
     * @return bool[]
     */
    private function getOpenAPINullablesSetToNull(): array
    {
        return $this->openAPINullablesSetToNull;
    }

    /**
     * Setter - Array of nullable field names deliberately set to null.
     *
     * @param bool[] $openAPINullablesSetToNull
     */
    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
    {
        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
    }

    /**
     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
     * $this->openAPINullablesSetToNull array.
     *
     * @param mixed $defaultValue
     */
    private function setIfExists(string $variableName, array $fields, $defaultValue): void
    {
        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
            $this->openAPINullablesSetToNull[] = $variableName;
        }

        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
    }
}
